#!/usr/bin/env python

# this simple script was used to convert the original implementation's
# method of printing things by sending strings to the `momma()` method,
# which was one line long and forwarded them to `print`.

# the script demonstrates redirection of standard output to file output,
# capturing groups in regexen, and string interpolation.


import string
import re
import sys



in_file = open("mommabot.py", 'r')
sys.stdout = open("test_harness.py", 'w')

regex = re.compile('(\s+)momma\ ?\((.*)\)')

for line in in_file.read().split("\n"):
	match = regex.match(line)
	if match == None:
		print line
	else:
		print "%(whitespace)sprint %(lexi)s" % {"whitespace":match.group(1), "lexi":match.group(2)}
